﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using System.Configuration;
using System.Data;

using System.Web.Security;

using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.UI.DataVisualization.Charting;
using System.Drawing;
namespace HZ.Supervise.Web.Secondphase.ShowImage.test
{
    public partial class 柱状图 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //数据源
            int[] test = { 100, 70, 40, 30, 80, 60, 50, 99, 50, 90};  //所有药品
            int[] test1 = { 30, 15, 12, 10, 10, 30, 10, 20, 11, 20 };  //基本药品
            int[] test3 = { 70, 45, 28, 20, 70, 30, 40, 79, 39, 70 };  //非基本药品
            string [] test4 = { "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月" };  //非基本药品

            //***************** 所有药品 曲线  *******************/
            Series series1 = new Series("所有药品");
            series1.ChartType = SeriesChartType.Spline;
            series1.BorderWidth = 3;
            series1.ShadowOffset = 2;
            for (int i = 0; i < test.Count(); i++) //添加数据
            {
                series1.Points.AddY(test[i]);
            }

            series1.IsValueShownAsLabel = true;
            Chart1.Series.Add(series1);
            Chart1.Series["所有药品"].MarkerStyle = MarkerStyle.Diamond;    //设置点标记样式(此为圆点)
            Chart1.Series["所有药品"].MarkerSize = 8;    //设置线节点大小

            //***************** 基本药品 柱状  *******************/
            Series series2 = new Series("基本药品");
            series2.ChartType = SeriesChartType.Column;
            series2.BorderWidth = 3;
            series2.ShadowOffset = 2;
            series2.Color = Color.Red;
            for (int i = 0; i < test1.Count(); i++) //添加数据
            {
                series2.Points.AddY(test1[i]);
            }

            series2.IsValueShownAsLabel = true;
            Chart1.Series.Add(series2);

            //***************** 非基本药品 柱状  *******************/
            Series series3 = new Series("非基本药品");
            series3.ChartType = SeriesChartType.Column;
            series3.BorderWidth = 3;
            series3.ShadowOffset = 2;
            series3.Color = Color.Green;
            for (int i = 0; i < test3.Count(); i++) //添加数据
            {
                series3.Points.AddXY(test4[i], test3[i]);//
            }
            series3.IsValueShownAsLabel = true;

            Chart1.Series.Add(series3);


            Title t2 = new Title("医院采购情况");            //图片标题

            Chart1.Titles.Add(t2);
            Chart1.Width = (test.Count() * 60 + 200) >=1000 ? test.Count() * 600 + 200 : 1000;    //图片宽度
            Chart1.Height = 400;                      //图片高度

            //作图区的显示属性设置
            Chart1.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true ;
            Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false;
            //背景色设置
            Chart1.ChartAreas["ChartArea1"].ShadowColor = Color.Transparent;
            Chart1.ChartAreas["ChartArea1"].BackColor = Color.Azure;         //该处设置为了由天蓝到白色的逐渐变化
            Chart1.ChartAreas["ChartArea1"].BackGradientStyle = GradientStyle.TopBottom;
            Chart1.ChartAreas["ChartArea1"].BackSecondaryColor = Color.White;
            //X,Y坐标线颜色和大小
            Chart1.ChartAreas["ChartArea1"].AxisX.LineColor = Color.Blue;
            Chart1.ChartAreas["ChartArea1"].AxisY.LineColor = Color.Blue;
            Chart1.ChartAreas["ChartArea1"].AxisX.LineWidth = 2;
            Chart1.ChartAreas["ChartArea1"].AxisY.LineWidth = 2;

            Chart1.ChartAreas["ChartArea1"].AxisY.Title = "交易金额（万元）";
            Chart1.ChartAreas["ChartArea1"].AxisX.Title = "交易日期";
            //中间X,Y线条的颜色设置
            Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.LineColor = Color.Blue;
            Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.LineColor = Color.Blue;
            //X.Y轴数据显示间隔
            Chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;  //X轴数据显示间隔
            Chart1.ChartAreas["ChartArea1"].AxisY.Interval = test1.Count();
            //X轴线条显示间隔
            Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Interval = 1;
            
        }
    }
}
